package com.arron.DesignMode.观察者.Observable;

import java.util.Observable;

/**
 *  是一个主题，可观察的对象
 */
public class WeatherDataObservable  extends Observable {



    //温度
    private float temperature;

    //湿度
    private float humidity;

    //压力
    private float pressure;


    // 接收外部的通知，更新数据
    public  void  setData(float temperature, float humidity, float pressure){
        this.humidity = humidity;
        this.temperature = temperature;
        this.pressure = pressure;
        setChanged();
        //通知所有的观察者，及订阅了这个主题的订阅者
        notifyObservers();


    }


    public float getTemperature() {
        return temperature;
    }

    public float getHumidity() {
        return humidity;
    }

    public float getPressure() {
        return pressure;
    }
}
